﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Admin/MasterPage_Edit.master" AutoEventWireup="true" CodeFile="PhoneEdit.aspx.cs"
    Inherits="Phone_PhoneEdit" ValidateRequest="false" %>

<asp:Content ID="Content1" ContentPlaceHolderID="Head" runat="Server">

    <link href="/Resources/js/fancyBox/source/helpers/jquery.fancybox-thumbs.css" rel="stylesheet" />
    <script src="/Resources/js/fancyBox/source/helpers/jquery.fancybox-thumbs.js"></script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="Title" runat="Server">
    <asp:Literal ID="lbl_Title" runat="server">产品资料录入</asp:Literal>
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="Content" runat="Server">
    <div class="ht-panel-edit">
        <table class="ht-edit-table">
            <tr>
                <th>产品类型：</th>
                <td colspan="5">
                    <asp:CheckBoxList ID="cbl_PhoneType" runat="server" RepeatDirection="Horizontal" RepeatLayout="Flow" CssClass="ht-checkboxlist"></asp:CheckBoxList>

                    <p class="PhoneType">
                        <asp:Literal ID="lbl_PhoneType" runat="server"></asp:Literal>
                    </p>
                </td>
            </tr>
            <tr>
                <th>Product Picture：</th>
                <td colspan="5">
                    <div id="div_ImageList"></div>
                    <%if (Action != "Detail")
                      {%>
                    <a id="btn_AddProductPicture" href="javascript:void(0)">添加图片</a>
                    <%} %>
                    <asp:HiddenField ID="hf_ProductPicture" runat="server" />
                </td>
            </tr>
            <tr>
                <th>PART NO.：</th>
                <td>
                    <asp:TextBox ID="txt_PartNo" runat="server" CssClass="ht-textbox" Width="100px"></asp:TextBox>
                    <asp:RequiredFieldValidator runat="server" ErrorMessage="不能为空" ControlToValidate="txt_PartNo"></asp:RequiredFieldValidator>
                    <asp:Label ID="lbl_PartNo" runat="server"></asp:Label>
                </td>
                <th>供应商型号：</th>
                <td>
                    <asp:TextBox ID="txt_PhoneCode" runat="server" CssClass="ht-textbox" Width="100px"></asp:TextBox>
                    <asp:Label ID="lbl_PhoneCode" runat="server"></asp:Label>
                </td>
                <th>供应商资料：</th>
                <td>
                    <asp:DropDownList ID="ddl_SupplierId" runat="server" CssClass="ht-select" Width="100px"></asp:DropDownList>
                    <asp:Label ID="lbl_SupplierId" runat="server"></asp:Label>
                </td>


            </tr>
            <tr>
                <th>价格（人民币）：</th>
                <td>
                    <asp:TextBox ID="txt_RMB" runat="server" CssClass="ht-textbox text-number" Width="100px"></asp:TextBox>
                    <asp:Label ID="lbl_RMB" runat="server"></asp:Label>
                </td>
                <th>Unit Price(USD).：</th>
                <td>
                    <asp:TextBox ID="txt_USD" runat="server" CssClass="ht-textbox text-number" Width="100px"></asp:TextBox>
                    <asp:Label ID="lbl_USD" runat="server"></asp:Label>
                </td>

                <th>MOQ(PCS)：</th>
                <td>
                    <asp:TextBox ID="txt_PCS" runat="server" CssClass="ht-textbox text-number" Width="100px"></asp:TextBox>
                    <asp:Label ID="lbl_PCS" runat="server"></asp:Label>
                </td>
            </tr>
            <tr>
                <th>产品屏幕尺寸：</th>
                <td>
                    <asp:DropDownList ID="ddl_Screen" runat="server" CssClass="ht-select" Width="100px"></asp:DropDownList>
                    <asp:Label ID="lbl_Screen" runat="server"></asp:Label>
                </td>
                <th>产品芯片类型：</th>
                <td>
                    <asp:DropDownList ID="ddl_Chip" runat="server" CssClass="ht-select" Width="100px"></asp:DropDownList>
                    <asp:Label ID="lbl_Chip" runat="server"></asp:Label>
                </td>
                <th>产品系列归类：</th>
                <td>
                    <asp:DropDownList ID="ddl_Series" runat="server" CssClass="ht-select" Width="100px"></asp:DropDownList>
                    <asp:Label ID="lbl_Series" runat="server"></asp:Label>
                </td>
            </tr>
            <tr>

                <th>系统：</th>
                <td>
                    <asp:DropDownList ID="ddl_System" runat="server" CssClass="ht-select" Width="100px"></asp:DropDownList>
                    <asp:Label ID="lbl_System" runat="server"></asp:Label>
                </td>
                <th>频段：</th>
                <td>
                    <asp:DropDownList ID="ddl_Frequency" runat="server" CssClass="ht-select" Width="100px"></asp:DropDownList>
                    <asp:Label ID="lbl_Frequency" runat="server"></asp:Label>
                </td>
                <th>网络：</th>
                <td>
                    <asp:DropDownList ID="ddl_NetWork" runat="server" CssClass="ht-select" Width="100px"></asp:DropDownList>
                    <asp:Label ID="lblNetWork" runat="server"></asp:Label>
                </td>
            </tr>
            <tr>
                <th>卡槽：</th>
                <td>
                    <asp:DropDownList ID="DropDownList4" runat="server" CssClass="ht-select" Width="100px"></asp:DropDownList>
                    <asp:Label ID="Label4" runat="server"></asp:Label>
                </td>
                <th>屏幕像素：</th>
                <td>
                    <asp:DropDownList ID="DropDownList5" runat="server" CssClass="ht-select" Width="100px"></asp:DropDownList>
                    <asp:Label ID="Label5" runat="server"></asp:Label>
                </td>
                <th>内存RAM：</th>
                <td>
                    <asp:DropDownList ID="DropDownList6" runat="server" CssClass="ht-select" Width="100px"></asp:DropDownList>
                    <asp:Label ID="Label6" runat="server"></asp:Label>
                </td>
            </tr>
            <tr>
                <th>内存ROM：</th>
                <td>
                    <asp:DropDownList ID="DropDownList7" runat="server" CssClass="ht-select" Width="100px"></asp:DropDownList>
                    <asp:Label ID="Label7" runat="server"></asp:Label>
                </td>
                <th>摄像头前：</th>
                <td>
                    <asp:DropDownList ID="DropDownList8" runat="server" CssClass="ht-select" Width="100px"></asp:DropDownList>
                    <asp:Label ID="Label8" runat="server"></asp:Label>
                </td>
                <th>摄像头后：</th>
                <td>
                    <asp:DropDownList ID="DropDownList9" runat="server" CssClass="ht-select" Width="100px"></asp:DropDownList>
                    <asp:Label ID="Label9" runat="server"></asp:Label>
                </td>
            </tr>
            <tr>
                <th>电池：</th>
                <td>
                    <asp:DropDownList ID="DropDownList10" runat="server" CssClass="ht-select" Width="100px"></asp:DropDownList>
                    <asp:Label ID="Label10" runat="server"></asp:Label>
                </td>
                <th>耳机：</th>
                <td>
                    <asp:DropDownList ID="DropDownList11" runat="server" CssClass="ht-select" Width="100px"></asp:DropDownList>
                    <asp:Label ID="Label11" runat="server"></asp:Label>
                </td>
                <th>充电器：</th>
                <td>
                    <asp:DropDownList ID="DropDownList12" runat="server" CssClass="ht-select" Width="100px"></asp:DropDownList>
                    <asp:Label ID="Label12" runat="server"></asp:Label>
                </td>
            </tr>
            <tr>
                <th>颜色：</th>
                <td>
                    <asp:DropDownList ID="DropDownList13" runat="server" CssClass="ht-select" Width="100px"></asp:DropDownList>
                    <asp:Label ID="Label13" runat="server"></asp:Label>
                </td>
                <th>配件：</th>
                <td>
                    <asp:DropDownList ID="DropDownList14" runat="server" CssClass="ht-select" Width="100px"></asp:DropDownList>
                    <asp:Label ID="Label14" runat="server"></asp:Label>
                </td>
                <th>尺寸：</th>
                <td>
                    <asp:DropDownList ID="DropDownList15" runat="server" CssClass="ht-select" Width="100px"></asp:DropDownList>
                    <asp:Label ID="Label15" runat="server"></asp:Label>
                </td>
            </tr>



            <tr>
                <th>Sale Point.：</th>
                <td colspan="5">
                    <asp:TextBox ID="txt_SalePoint" runat="server" TextMode="MultiLine" Width="790" Height="240" CssClass="ht-area"></asp:TextBox>
                    <asp:Label ID="lbl_SalePoint" runat="server"></asp:Label>
                </td>
            </tr>

            <tr style="display: none">
                <th>是否启用：</th>
                <td colspan="5">
                    <asp:CheckBox ID="ch_Valid" runat="server" Checked="true" />
                </td>
            </tr>
            <tr>
                <th>Specification：</th>
                <td colspan="5">
                    <asp:TextBox ID="txt_Specification" runat="server" TextMode="MultiLine" Width="800" Height="600"></asp:TextBox>
                </td>
            </tr>
        </table>
    </div>

</asp:Content>
<asp:Content ID="Content5" ContentPlaceHolderID="Buttoms" runat="Server">
    <asp:LinkButton ID="btn_Modify" runat="server" Text="编辑" OnClick="btn_Modify_Click" CssClass="easyui-linkbutton" data-options="iconCls:'icon-edit'" />
    <asp:LinkButton ID="btn_Save" runat="server" Text="保存" OnClick="btn_Save_Click" CssClass="easyui-linkbutton" data-options="iconCls:'icon-save'" />
    <a id="btn_Back" runat="server" href="javascript:Cancel()" class="easyui-linkbutton" data-options="iconCls:'icon-back'">返回</a>
</asp:Content>
<asp:Content ID="Content4" ContentPlaceHolderID="Footer" runat="Server">
    <script>
        KindEditor.ready(function (K) {
            var editor = K.create('#<%=txt_Specification.ClientID %>', {
                //allowFileManager: true,
                filterMode: false,
                autoHeightMode: true,
                afterCreate: function () {
                    this.loadPlugin('autoheight');
                },
                pasteType: 1
            });

            if ($('#<%=txt_Specification.ClientID%>').attr('disabled') == 'disabled') {
                editor.readonly();
            }

            K('#<%=btn_Save.ClientID%>').click(function (e) {
                $('#<%=txt_Specification.ClientID%>').val(editor.html());
            });

            var pic_editor = K.editor({
                uploadJson: '/Resources/js/kindeditor/asp.net/image_upload_json.ashx',
                fileManagerJson: '/Resources/js/kindeditor/asp.net/image_manager_json.ashx',
                allowFileManager: true
            });
            K('#btn_AddProductPicture').click(function () {
                var td = K(this).parent();
                pic_editor.loadPlugin('insertfile', function () {
                    pic_editor.plugin.fileDialog({
                        fileUrl: '',
                        clickFn: function (url, title) {
                            AddPicture(url, '');
                            pic_editor.hideDialog();
                        }
                    });
                });
            });
        });

        var $hf_ProductPicture = $('#<%=hf_ProductPicture.ClientID%>');
        var jsonObj = new Array();

        function AddPicture(url, id) {
            var _html = '';
            //_html += '<div><img src="' + url + '" onclick="showPicture(\'' + url + '\')"/><span onclick="delPicture(this,\'' + id + '\')" style="<%=Action=="Detail"?"display:none":""%>">X</span></div>';
            _html += '<div><a class="fancybox-thumbs" data-fancybox-group="thumb" href="' + url + '">'
                + '<img src="' + url + '" /></a>'
                + '<span onclick="delPicture(this,\'' + id + '\')" style="<%=Action=="Detail"?"display:none":""%>">X</span></div>';
            $('#div_ImageList').append(_html);

            jsonObj.push({ id: id, url: url });

            $hf_ProductPicture.val(JSON.stringify(jsonObj));



            $('.fancybox-thumbs').fancybox({
                prevEffect: 'none',
                nextEffect: 'none',

                closeBtn: true,
                arrows: true,
                nextClick: true,

                helpers: {
                    thumbs: {
                        width: 50,
                        height: 50
                    }
                }
            });
        }

        function delPicture(obj, id) {
            for (var i = 0; i < jsonObj.length; i++) {
                if (id != "" && jsonObj[i].id == id) {
                    jsonObj.splice(i, 1);
                    break;
                }
            }
            $hf_ProductPicture.val(JSON.stringify(jsonObj));
            $(obj).parent().remove();
        }

        //加载图片
        $(function () {
            var str = $hf_ProductPicture.val();
            if (str != "") {
                var picSrcs = JSON.parse(str);
                for (var i = 0; i < picSrcs.length; i++) {
                    if (picSrcs[i].url.length > 5) {
                        AddPicture(picSrcs[i].url, picSrcs[i].id);
                    }
                }
            }
        });

    </script>
    <style type="text/css">
        #div_ImageList {
            position: relative;
        }

            #div_ImageList div {
                float: left;
                width: 100px;
                height: 80px;
                margin: 4px;
                border: solid 1px #808080;
            }

                #div_ImageList div:hover {
                    border: solid 1px #ff0000;
                }

                #div_ImageList div img {
                    width: 100%;
                    height: 100%;
                    cursor: pointer;
                }

                #div_ImageList div span {
                    position: absolute;
                    margin-left: -16px;
                    background: #808080;
                    color: #fff;
                    line-height: 16px;
                    padding: 0 4px;
                }

                    #div_ImageList div span:hover {
                        background: #ff0000;
                        cursor: pointer;
                    }

        #Specification {
        }

            #Specification table {
                clear: both;
            }

        .PhoneType span {
            margin: 0 10px;
        }
    </style>

    <script>
        //价格输入
        $(function () {
            $('.text-number').blur(function () {
                var _num = parseFloat($(this).val()).toFixed(2);
                _num = (_num == 'NaN') ? '' : _num;
                $(this).val(_num);
            });
        });
    </script>

</asp:Content>

